﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using SeDuce.BLL;

public partial class UserControls_UCProductsHistory : System.Web.UI.UserControl
{
    Lazy_Yu<ProductBLL> lazyProductBLL = new Lazy_Yu<ProductBLL>(() => new ProductBLL());
    public ProductBLL LazyProductBLL
    {
        get { return this.lazyProductBLL.Value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        HttpCookie cookie = Request.Cookies["SeDuce_Products_History"];
        if (cookie != null)
        {
            List<string> productIDs = cookie.Value.Split(',').ToList<string>();
            string IDs = string.Join(",", productIDs.ToArray<string>());
            this.rptProducts.DataSource = LazyProductBLL.GetProductsByIDs(IDs);
            this.rptProducts.DataBind();
        }
    }

    protected string GetProductStatus(int statusID)
    {
        string status = string.Empty;
        switch (statusID)
        {
            case 1:
                status = ResolveUrl("~/images/status_spot.gif");
                break;
            case 2:
                status = ResolveUrl("~/images/status_reservation.gif");
                break;
            case 3:
                status = ResolveUrl("~/images/status_sale.gif");
                break;
            case 4:
                status = ResolveUrl("~/images/status_soldout.gif");
                break;
            default:
                break;
        }
        return status;
    }
}